<?php
/**
 * Row.php
 *
 * @category    Madoqua
 * @package     Module
 * @subpackage  Blog
 */

/** base class */
require_once 'Zend/Db/Table/Row.php';

/** lucene indexer */
require_once 'Madoqua/Search/Indexer.php';

/**
 * Blog_Post_Row
 *
 * @category    Madoqua
 * @package     Module
 * @subpackage  Blog
 */
class Blog_Post_Row extends Zend_Db_Table_Row
{
    /**
     * get
     *
     * @param string $what
     * @return mixed
     */
    public function __get($what)
    {
        if ($what == 'categories') {
            return $this->findManyToManyRowset('Blog_Category', 'Blog_PostCategory');
        } else {
            return parent::__get($what);
        }
    }

    /**
     * post insert hook
     */
    protected function _postInsert() {
        Madoqua_Search_Indexer::indexPost($this);
    }

    /**
     * post update hook
     */
    protected function _postUpdate() {
        Madoqua_Search_Indexer::indexPost($this);
    }
}